﻿//07.Write a program that reads a number N and calculates 
//the sum of the first N members of the sequence of Fibonacci: 
//0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, …
//Each member of the Fibonacci sequence (except the
//first two) is a sum of the previous two members.

using System;
using System.Numerics;

namespace Fibonacci
{
    class Fibonacci
    {
        static void Main()
        {
            Console.Write("Define the sum of how many Fibonacci numbers you want to calculate: ");
            int m = int.Parse(Console.ReadLine());

            BigInteger a = 0;
            BigInteger b = 1;
            BigInteger c = 1;
            BigInteger sum = 1;

            for (uint i = 3; i <= m; i++)
            {
                c = a + b;
                sum += c;
                a = b;
                b = c;
            }
            Console.WriteLine("The sum of the first {0} members of the Fibonacci sequence is {1}.", m, sum);
        }
    }
}
